import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:furaha_mkopo/commonTool/fm_language_tool.dart';
import 'package:furaha_mkopo/commonTool/fm_screen_tool.dart';
import 'package:furaha_mkopo/commonUI/fm_bottom_button.dart';
import 'package:furaha_mkopo/manager/fm_global_manager.dart';
import 'package:furaha_mkopo/manager/fm_location_manager.dart';
import 'package:get/get.dart';
import 'fm_launch_controller.dart';

class FMLaunchPage extends StatefulWidget {
  const FMLaunchPage({super.key});

  @override
  State<FMLaunchPage> createState() => _FMLaunchPageState();
}

class _FMLaunchPageState extends State<FMLaunchPage> {

  final controller = Get.put(FMLaunchController());

  @override
  void initState() {
    super.initState();
    controller.buildContext = context;
    FMGlobalManager().context = context;
  }

  @override
  void dispose() {
    Get.delete<FMLaunchController>();
    FMLocationManager().dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        _bgImageWidget(),
        _bottomButton()
      ],
    );
  }

  Widget _bgImageWidget() {
    return Positioned(
      top: 0,
      left: 0,
      bottom: 0,
      right: 0,
      child: Image.asset('assets/launch/Launch.png',fit: BoxFit.cover)
    );
  }

  Widget _bottomButton() {
    return Positioned(
      left: 38,
      right: 38,
      bottom: 62 + FMScreenTool.bottomPadding(context),
      child: FMBottomButton(
        title:FMLanguageTool.getText("Try again"),
        onTap: (){
          controller.tryClick();
        },
      )
    );
  }
}
